﻿package morn.core.components
{
    import flash.events.*;

    public class RadioButton extends Button
    {
        protected var _value:Object;

        public function RadioButton(param1:String = null, param2:String = "")
        {
            super(param1, param2);
            return;
        }// end function

        override protected function preinitialize() : void
        {
            super.preinitialize();
            _toggle = false;
            _autoSize = false;
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            _btnLabel.autoSize = "left";
            addEventListener(MouseEvent.CLICK, this.onClick);
            return;
        }// end function

        override protected function changeLabelSize() : void
        {
            _btnLabel.x = _bitmap.width + _labelMargin[0];
            _btnLabel.y = (_bitmap.height - _btnLabel.height) * 0.5 + _labelMargin[1];
            return;
        }// end function

        override public function commitMeasure() : void
        {
            exeCallLater(this.changeLabelSize);
            return;
        }// end function

        protected function onClick(event:Event) : void
        {
            selected = true;
            return;
        }// end function

        public function get value() : Object
        {
            return this._value != null ? (this._value) : (label);
        }// end function

        public function set value(param1:Object) : void
        {
            this._value = param1;
            return;
        }// end function

    }
}
